package com.dstz.bpm.api.constant;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public enum OpinionStatus {
   START("start", "提交"),
   CREATE("create", "创建"),
   END("end", "结束"),
   AWAITING_CHECK("awaiting_check", "待审批"),
   AGREE("agree", "同意"),
   OPPOSE("oppose", "反对"),
   ABANDON("abandon", "弃权"),
   REJECT("reject", "驳回"),
   REJECT_TO_START("rejectToStart", "驳回到发起人"),
   REVOKER("revoker", "撤回"),
   REVOKER_TO_START("revoker_to_start", "撤回到发起人"),
   SIGN_PASSED("signPass", "会签通过"),
   SIGN_NOT_PASSED("signNotPass", "会签不通过"),
   SIGN_RECYCLE("signRecycle", "会签回收"),
   SKIP("skip", "跳过执行"),
   TURN("turn", "转办"),
   CANCELLED("cancelled", "任务取消"),
   MANUAL_END("manualEnd", "人工终止");

   private String key = "";
   private String value = "";
   protected static Logger LOG = LoggerFactory.getLogger(OpinionStatus.class);

   private OpinionStatus(String key, String value) {
      this.key = key;
      this.value = value;
   }

   public String getKey() {
      return this.key;
   }

   public void setKey(String key) {
      this.key = key;
   }

   public String getValue() {
      return this.value;
   }

   public void setValue(String value) {
      this.value = value;
   }

   public String toString() {
      return this.key;
   }

   public static OpinionStatus fromKey(String key) {
      OpinionStatus[] var1 = values();
      int var2 = var1.length;

      for(int var3 = 0; var3 < var2; ++var3) {
         OpinionStatus c = var1[var3];
         if (c.getKey().equalsIgnoreCase(key)) {
            return c;
         }
      }

      LOG.warn("OpinionStatus 转换失败！ 无法查找到对应的 值：{}", key);
      return null;
   }

   public static OpinionStatus getByActionName(String actionName) {
      ActionType action = ActionType.fromKey(actionName);
      switch(action) {
      case AGREE:
         return AGREE;
      case SIGNAGREE:
         return SIGN_PASSED;
      case OPPOSE:
         return OPPOSE;
      case SIGNOPPOSE:
         return SIGN_NOT_PASSED;
      case REJECT:
         return REJECT;
      case REJECT2START:
         return REJECT_TO_START;
      case RECOVER:
         return REVOKER;
      case START:
         return START;
      case MANUALEND:
         return MANUAL_END;
      case TASKCANCELLED:
         return CANCELLED;
      default:
         return AWAITING_CHECK;
      }
   }
}
